package com.xl.web;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.SessionAttributes;

import javax.servlet.http.HttpSession;
import java.text.MessageFormat;

/**
 * Created with 徐立.
 *
 * @author 徐立
 * @date 2021-05-04
 * @time 13:02
 * To change this template use File | Settings | File Templates.
 */
@RestController
@RequestMapping("/session")
@SessionAttributes
@Slf4j
public class SessionAction {
    @GetMapping("/test")
    public String test(HttpSession session) {
        Thread thread = Thread.currentThread();
        String msg = MessageFormat.format("线程id{0},线程名称:{1},session的id：{2}", thread.getId(), thread.getName(), session.getId());
        log.info(msg);
        return msg;
    }
}
